<template>
	<!--商品瀑布流-->
	<view class="shop">
		<navigator :url="'/pages/convert/changedetails?shopid='+item.id" class="shop-item" v-for="(item,index) in shoplist"
		 :key="index">
			<image class="shopimg" :src="item.loaded?item.picture:'/static/image/defaultimg.png'" lazy-load="true" mode="aspectFill" @load="onImageLoad('shoplist',index)"></image>
			<view class="shop-text">
				<view class="shop-title">{{item.title}}</view>
				<view class="shop-duihuan">已兑{{item.exchange}}</view>
				<view class="shop-bottom">
					<view class="bottom-left">
						<image src="../../static/image/money-1.png" mode="aspectFill"></image>
						<view class="prize">{{item.amount}}{{parseFloat(item.price)>0 ?'+'+item.price+'元':''}}</view>
					</view>
					<view class="bottom-right">
						包邮
					</view>
				</view>
			</view>
		</navigator>
	</view>
</template>

<script>
	export default {
		name: 'shop',
		props: {
			categoryid: {
				type: Number,
				default: 0,
			},
			shoplist: {
				type: Array,
				default () {
					return []
				}
			}
		},
		methods: {
			onImageLoad(key, index) {
				//加载完之后显示图片
				this.$set(this[key][index], 'loaded', 'loaded'); 
			}
		}
	}
</script>

<style lang="scss">
	.shop {
		width: 97vw;
		margin: 0 auto;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;

		.shop-item {
			border-radius: 15rpx;
			background-color: #fff;
			width: 360rpx;
			height: 540rpx;
			margin-bottom: 20rpx;

			.shopimg {
				width: 360rpx;
				height: 354rpx;
				border-top-left-radius: 15rpx;
				border-top-right-radius: 15rpx;
			}

			.shop-text {
				display: flex;
				flex-direction: column;
				justify-content: flex-start;
				margin: 15rpx 20rpx;

				.shop-title {
					font-size: 28rpx;
					font-weight: bold;
					color: #5a5a5a;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}

				.shop-duihuan {
					font-size: 20rpx;
					color: #919191;
					margin: 20rpx 0;
				}

				.shop-bottom {
					display: flex;
					justify-content: space-between;
					align-items: center;
					color: #e9564f;

					.bottom-left {
						display: flex;

						image {
							width: 30rpx;
							height: 30rpx;
							margin-right: 10rpx;
						}

						.prize {
							font-size: 25rpx;
							font-weight: bold;
						}
					}

					.bottom-right {
						background-color: #ffeef1;
						width: 70rpx;
						height: 35rpx;
						border-radius: 10rpx;
						font-size: 20rpx;
						display: flex;
						justify-content: center;
						align-items: center;

					}
				}
			}

		}
	}
</style>
